var button = document.getElementById("button");
var workList=document.getElementById("workList");
var finishList=document.getElementById("finishList")
var work=[];
var finish=[];
var i=0;
button.onclick = function(){
    work[i]=document.createElement("li");
    initElement(work[i]);
    workList.appendChild(work[i]);
    work[i].childNodes[0].focus();
    i++;
};
function initElement(element){
    var text=document.createElement("input");
    var finish=document.createElement("button");
    var cancel=document.createElement("button");
    text.className="input";
    finish.className="finish";
    cancel.className="cancel";
    cancel.innerText="删除";
    finish.innerText="完成";
    finish.onclick=change;
    cancel.onclick=remove;
    element.className="active";
    element.appendChild(text);
    element.appendChild(cancel);
    element.appendChild(finish);
}
function remove(){
    this.parentNode.parentNode.removeChild(this.parentNode);
}
function change(){
        if(this.parentNode.parentNode.id=="workList"){
            this.innerText="重置";
            this.parentNode.childNodes[0].setAttribute("readOnly",true);
            finishList.appendChild(this.parentNode);
        }else{
            this.innerText="完成";
            this.parentNode.childNodes[0].removeAttribute("readOnly");
            workList.appendChild(this.parentNode);
        }
}